/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import state from './state.js';
import CustomizedInformationPanelParams from './CustomizedInformationPanelParams.js';

export default {
  customizedInformationPanelConfig() {
    return CustomizedInformationPanelParams.getConfig({
      column: 3
    })
  },
  customizedInformationPanelTitle() {
    let v = {
      date: '9月5日',
      result: '健康指数:91分'
    }
    return CustomizedInformationPanelParams.getTitle({
      subTitle: v.date + ' ' + v.result
    })
  },
  customizedInformationPanelRouter() {
    let params = [1, 2, 3]
    return CustomizedInformationPanelParams.getRouter({
      uri: 'pages/services/services',
      params: params,
    })
  },
  customizedInformationPanelData() {
    // 模拟接口数据转组件数据
    let result = [0, 1, 2, 3, 4, 5, 6, 7, 8]

    let data = result.reduce((arr, v) => {
      if (v == 1) {
        let item = CustomizedInformationPanelParams.getItem({
          value: '正常',
          description: 'D' + v,
          type: state.TYPE.HEALTHY,
        })
        arr.push(item)
      } else if (v == 2) {
        let item = CustomizedInformationPanelParams.getItem({
          value: '偏高',
          description: 'D' + v,
          type: state.TYPE.HIGH
        })
        arr.push(item)
      } else if (v == 3) {
        let item = CustomizedInformationPanelParams.getItem({
          value: '高',
          description: 'D' + v,
          type: state.TYPE.OVERWEIGHT
        })
        arr.push(item)
      } else {
        let item = CustomizedInformationPanelParams.getItem({
          value: 'V' + v,
          unit: 'bmp',
          description: 'D' + v,
        })
        arr.push(item)
      }
      return arr;
    }, [])

    return CustomizedInformationPanelParams.getData({
      items: data
    })
  }
}